package com.jerome.rmi.util;

import com.jerome.rmi.constants.RmiConstant;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * LocateRegistry util
 * @author jerome
 * @date 2023/7/29
 */
public class RegistryUtil {
    private static Registry registry;

    public static Registry getRegistry() throws RemoteException {
        if (registry == null) {
            registry = LocateRegistry.createRegistry(RmiConstant.RMI_PORT);
        }
        return registry;

    }
}
